<?php
/**
 + Created by:	Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webitsolution.com , info@webitsolution.com
				www.wrecruit.com, developer@wrecruit.com
 * Created on:	Dec 30, 2012
 ^
 + Project: 		WRecruit 
 * File Name:	module/jsjobcategories.php
 ^ 
 * Description: Module for WRecruit
 ^ 
 * History:		1.0.0 - Dec 30, 2012
 ^ 
 */

defined('_JEXEC') or die('Restricted access');

/** scs */
if($params->get('Itemid')) $itemid = $params->get('Itemid');			
else $itemid =  JRequest::getVar('Itemid');
$componentAdminPath = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_wrecruit';
$componentPath =  'components' . DS . 'com_wrecruit';
require_once $componentPath . DS . 'models' . DS . 'mpwrecruit.php';
$config = array( 'table_path' => $componentAdminPath . DS . 'tables');
$model = new WRecruitModelMpWRecruit($config);
$industries = $model->getJobCompanies('');
//echo '<pre>'; print_r($industries);exit;
?>
<div class="head-title">
	<h2>Jobs by Industry</h2>
</div>
<?php
if ($industries) {
	$industryjobs = array();
	foreach ($industries as $industry) {
		if($industry->companyinjobs > 0 )
			$industryjobs[] = $industry;
	}
	if(count($industryjobs)) {
		$numitems = count($industryjobs);
		$firstrow = $secondrow = $thirdrow = (int)($numitems / 3);
		if($numitems % 3 > 0){
			$firstrow += 1;
		}
		if($numitems % 3 == 2){
			$secondrow += 1;
		}
		for($i = 0; $i < $numitems; $i++){
			if($i == 0){
				echo '<ul class="left">';
			}
			elseif($i == $firstrow){
				echo '</ul>';
				echo '<ul class="middle">';
			}
			elseif($i == ($firstrow + $secondrow)){
				echo '</ul>';
				echo '<ul class="right">';
			}
			$class = '';
			if(($i == $firstrow - 1) || ($i == ($firstrow + $secondrow) - 1) || ($i == ($numitems) - 1)){
				$class = ' class="last"';
			}
			$lnks = 'index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=company_jobs&cd='. $industryjobs[$i]->id .'&Itemid='.$itemid;
			$lnks = JRoute::_($lnks);
			echo '<li' . $class . '><a href="' . $lnks . '">' . ($i + 1) . '. ' . $industryjobs[$i]->name . '</a><span>(' . $industryjobs[$i]->companyinjobs . ')</span></li>';
			if($i == $numitems - 1){
				echo '</ul>';
			}	
		}
	}
}
?>

